package com.android.miniskirt.ui;

import com.android.miniskirt.R;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;

public class PageLoad extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pageload);
        
        LinearLayout layout=(LinearLayout)findViewById(R.id.layout);
        AutoBackground(this, layout, R.drawable.bg_v, R.drawable.bg_h);
    }
    
    public static int ScreenOrient(Activity activity)
    {
        int orient = activity.getRequestedOrientation(); 
        if(orient != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && orient != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
             WindowManager windowManager = activity.getWindowManager();  
             Display display = windowManager.getDefaultDisplay();  
             int screenWidth  = display.getWidth();  
             int screenHeight = display.getHeight();  
             orient = screenWidth < screenHeight ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        }
        return orient;
    }
    
    public static void AutoBackground(Activity activity,View view,int Background_v, int Background_h)
    {
        int orient=ScreenOrient(activity);
        if (orient == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
            view.setBackgroundResource(Background_v);
        }else{
            view.setBackgroundResource(Background_h);
        }  
    }
}